//
//  YQLeftHeadView.m
//  NewRetail
//
//  Created by yuqin on 2019/6/24.
//  Copyright © 2019年 yuqin. All rights reserved.
//

#import "YQLeftHeadView.h"

@interface YQLeftHeadView ()

@property (nonatomic, strong) UILabel *theTitleLab;
@property (nonatomic, strong) UILabel *walletListLab;
@property (nonatomic, strong) UIView *lineView;

@end

@implementation YQLeftHeadView

- (void)setupContentView {
    //layout
    [self addSubview:self.theTitleLab];
    [self addSubview:self.showAndHideBtn];
    [self addSubview:self.totalCoinlab];
    [self addSubview:self.lineView];
    [self addSubview:self.walletListLab];
    
    [self.theTitleLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(kMargin_left);
        make.top.mas_equalTo(FIT(0));
        make.size.mas_equalTo(CGSizeMake(FIT(45), FIT(21)));
    }];
    
    [self.showAndHideBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.theTitleLab.mas_right).mas_equalTo(FIT(10));
        make.centerY.mas_equalTo(self.theTitleLab.mas_centerY);
        make.size.mas_equalTo(CGSizeMake(FIT(20), FIT(15)));
    }];
    
    [self.totalCoinlab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(kMargin_left);
        make.top.equalTo(self.theTitleLab.mas_bottom).mas_equalTo(FIT(20));
        make.size.mas_equalTo(CGSizeMake(ScreenWidth-FIT(32), FIT(21)));
    }];
    
    [self.lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(kMargin_left);
        make.top.equalTo(self.totalCoinlab.mas_bottom).mas_equalTo(FIT(20));
        make.size.mas_equalTo(CGSizeMake(ScreenWidth-kMargin_left, FIT(1)));
    }];
    
    [self.walletListLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(kMargin_left);
        make.top.equalTo(self.lineView.mas_bottom).mas_equalTo(0);
        make.size.mas_equalTo(CGSizeMake(ScreenWidth-FIT(32), FIT(40)));
    }];
    
}

#pragma mark - dy
- (UILabel *)theTitleLab {
    if (!_theTitleLab) {
        _theTitleLab = [YQViewFactory labelWithTextColor:MainBlackColor textAlignment:NSTextAlignmentLeft fontSize:kLittleFont userBold:NO];
        _theTitleLab.text = @"总资产";
    }
    return _theTitleLab;
}

- (UIButton *)showAndHideBtn {
    if (!_showAndHideBtn) {
        _showAndHideBtn = [YQViewFactory buttonWithImage:YQ_IMAGE(@"eyes") target:self sel:@selector(showAndHideBtnAction:)];
        [_showAndHideBtn setImage:YQ_IMAGE(@"hide") forState:UIControlStateSelected];
//        _showAndHideBtn.backgroundColor = MainRedTextColor;
    }
    return _showAndHideBtn;
}

- (UILabel *)totalCoinlab {
    if (!_totalCoinlab) {
        _totalCoinlab = [YQViewFactory labelWithTextColor:MainBlackColor textAlignment:NSTextAlignmentLeft fontSize:kLittleFont userBold:NO];
        _totalCoinlab.text = @"0.000000 WDC";
    }
    return _totalCoinlab;
}

- (UIView *)lineView {
    if (!_lineView) {
        _lineView = [[UIView alloc] init];
        _lineView.backgroundColor = LineColor;
    }
    return _lineView;
}

- (UILabel *)walletListLab {
    if (!_walletListLab) {
        _walletListLab = [YQViewFactory labelWithTextColor:MainBlackColor textAlignment:NSTextAlignmentLeft fontSize:kLittleFont userBold:NO];
        _walletListLab.text = @"钱包列表";
    }
    return _walletListLab;
}

- (void)showAndHideBtnAction:(UIButton *)btn {
    btn.selected = !btn.selected;
    if (btn.selected == YES) {
        self.totalCoinlab.text = @"****** WDC";
    }else {
        self.totalCoinlab.text = @"0.000000 WDC";
    }
}

@end
